<?php
/**
 *Copyright (c) <2017> <copyright taodingfei>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

namespace Themis\Contracts\Container;

/**
 * Interface ContainerInterface
 * @package Themis\Contracts\Container
 */
interface ContainerInterface extends ContainerServiceInterface
{
    /**
     * 从容器中解析出$abstract对象
     *
     * @param string $abstract
     * @return mixed
     */
    public function make($abstract);

    /**
     * 判断容器中是否存在$abstract依赖
     *
     * @param string $abstract
     * @return bool
     */
    public function has($abstract);

    /**
     * 使用依赖注入实例化$abstract
     *
     * @param string $abstract
     * @param array|null $parameters
     * @return mixed
     */
    public function build($abstract, $parameters=array());

    /**
     * 使用依赖注入调用$callable，模拟call_user_func函数
     *
     * @param callable $callable
     * @param array $parameters
     * @return mixed
     */
    public function call($callable, $parameters=array());

    /**
     * 向容器中注入依赖关系
     *
     * @param string $abstract
     * @param null|callable|object $concrete
     * @param bool $shared
     */
    public function bind($abstract, $concrete=null, $shared=false);

    /**
     * 以共享的方式向容器注入依赖
     *
     * @param string $abstract
     * @param null|callable|object $concrete
     */
    public function share($abstract, $concrete=null);
}